ShowTable of Contents
This article will go through the steps required to set up a provided test project to test your custom XPages controls.
In this tutorial we will be using an example control project:
com.example.greenbox, but same steps can be applied to other controls.
To follow this tutorial, import the
com.example.greenbox project which can be found in the article's
Attachments list.
Configuring Test Project
In the
MANIFEST.MF in the test project, remove dependency on the
com.example.xsp project
Add a new dependency for your control (in our case it's
com.example.greenbox) so it looks like so:
In the project open
WEB-INF/xsp.properties file
Change the dependency from
com.example.library to your own (in our case it's
com.example.greenbox.library)
It should look like so:
xsp.library.depends=\
com.ibm.xsp.core.library,\
com.ibm.xsp.extsn.library,\
com.ibm.xsp.designer.library,\
com.ibm.xsp.domino.library,\
com.example.greenbox.library
Open
config.properties in the test project package
com.ibm.xsp.test.framework
Change the
target.
library and
NamingConvention.package.prefix to your own control
(in our case it's
com.example.greenbox.library and
com.example.greenbox respectively). It should look like so:
# The XspLibrary.getLibraryId() value of the library
# whose contents should be tested, defaults to none,
# meaning that only local xsp-configs are loaded.
target.library=com.example.greenbox.library
# Package name and component-type prefix, like "com.ibm.xsp" or
# "com.ibm.xsp.extlib", used in the NamingConventionTest
#NamingConvention.package.prefix=
NamingConvention.package.prefix=com.example.greenbox
# Extra libraries whose xsp-config files should be loaded
# when creating a registry
extra.library.depends.designtime.nonapplication=\
com.ibm.xsp.core.library,\
com.ibm.xsp.extsn.library,\
com.ibm.xsp.designer.library,\
com.ibm.xsp.domino.library
In the test project, open
pages/simpleTestOfExampleControl.xsp
Change the XPage(prefix, namespace, tag) to use your own control. In our case it should look like so:
Delete the contents of the
gen folder in the test project.
Re-run the tests. Refresh the test project.
gen folder should now contain generated Java Classes for the corresponding XPage above.
Before we continue to the next section, we need to fix a compile error in the
ExamplePrintTagNamesAndProps.
In the test project, open
ExamplePrintTagNamesAndProps.java from the
xsp.example.test.version package.
Somewhere around line #22 change the following code to use your own control (in our case it's Greenbox Library).
Change from:
tagsAndProps = filterToDependsLibrary(registry, (new ExampleLibrary()).getLibraryId(), tagsAndProps);
to
tagsAndProps = filterToDependsLibrary(registry, (new GreenboxLibrary()).getLibraryId(), tagsAndProps);
You might need to organize your imports (Ctrl+Shift+O) to remove unused references to the old control.
Renaming Test Project
The sample test project was named to use with the example control. In this section we will go through the steps to rename the test project to use with our control.
For the tutorial purpose, we will be renaming the project to our Greenbox example control but same steps can applied to your own control.
We will start with renaming the project name and proceed to packages after.
Right click on the
com.example.junit.tests project. Refactor -> Rename
Name the project to be
com.example.greenbox.junit.tests
We are going to do the same for the packages in the test project.
Right click on the
xsp.example.test package. Refactor -> Rename
Name the package to be
xsp.example.greenbox.test
Now your test project structure should look like so:
The
com.ibm.xsp.test.framework package should not be renamed as the name is required by the test framework.
Now we are going to rename Java Classes to reflect the the use of our control.
Right click on
ExampleTestSuite.java in the
com.example.greenbox.test package. Refactor -> Rename
Name it to be
GreenboxTestSuite like so
Follow the same pattern for the remaining Java Classes: replacing
Example[...] with
Greenbox[...].
So that the test project structure looks like so:
Running Test Framework and fixing fails